package com.hongye.consult.controller;

import com.hongye.common.enu.ResultEnum;
import com.hongye.common.utils.ResponseResult;
import com.hongye.consult.entity.HongyeAuditEntity;
import com.hongye.consult.service.BrokerService;
import com.hongye.consult.vo.BrokerParticularsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author fyd
 * @email 2104371759@qq.com
 * @date 2022/4/27
 * @time 8:37
 */
@RestController
@RequestMapping("consult/broker")
public class BrokerController {

    @Autowired
    private BrokerService brokerService;

    /**
     * 经纪人详情
     * @param id 经纪人编号
     * @return
     */
    @RequestMapping("/getBrokerParticulars")
    public BrokerParticularsVo getBrokerParticulars(@RequestParam("id") Integer id){
        return brokerService.getBrokerParticulars(id);
    }


    /**
     * 我想租个房
     * @param entity 表单
     * @return
     */
    @RequestMapping("/addAuditByRenting")
    public ResponseResult<Integer> addAuditByRenting(@RequestBody HongyeAuditEntity entity){
        Integer integer = brokerService.addAuditByRenting(entity);
        ResponseResult<Integer> result = new ResponseResult<>();
        if (integer > 0){
            result.setSuccess(ResultEnum.SUCCESS.getSuccess());
            result.setCode(ResultEnum.SUCCESS.getCode());
            result.setMessage(ResultEnum.SUCCESS.getMessage());
            result.setData(integer);
            return result;
        }else {
            result.setSuccess(ResultEnum.ERROR.getSuccess());
            result.setCode(ResultEnum.ERROR.getCode());
            result.setMessage(ResultEnum.ERROR.getMessage());
            return result;
        }
    }

}
